USE [master]
GO

/****** Object:  Database [TestFS_TwoTablesOneRelationshipCompKey]    Script Date: 09/11/2010 11:53:09 ******/
CREATE DATABASE [TestFS_TwoTablesOneRelationshipCompKey]
/*
//REMEMBER TO COMMENT THIS OUT - LET SQL SERVER DECIDE WHERE TO PUT THE DB FILES. THIS WILL PREVENT ANY ERRORS IF ANOTHER SQL SERVER IS INSTALLED IN A DIFFERENT LOCATION
 ON  PRIMARY 
( NAME = N'TestFS_TwoTablesOneRelationshipCompKey', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TestFS_TwoTablesOneRelationshipCompKey.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'TestFS_TwoTablesOneRelationshipCompKey_log', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\TestFS_TwoTablesOneRelationshipCompKey_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
*/
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [TestFS_TwoTablesOneRelationshipCompKey].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET ARITHABORT OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET  DISABLE_BROKER 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET  READ_WRITE 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET RECOVERY SIMPLE 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET  MULTI_USER 
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [TestFS_TwoTablesOneRelationshipCompKey] SET DB_CHAINING OFF 
GO

USE [TestFS_TwoTablesOneRelationshipCompKey]
GO
/****** Object:  Table [dbo].[ParentTable]    Script Date: 09/11/2010 15:28:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ParentTable](
	[ParentID] [uniqueidentifier] NOT NULL,
	[Parent2ID] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_ParentTable] PRIMARY KEY CLUSTERED 
(
	[ParentID] ASC, [Parent2ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ChildTable]    Script Date: 09/11/2010 15:28:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ChildTable](
	[ChildID] [uniqueidentifier] NOT NULL,
	[ParentRel1ID] [uniqueidentifier] NULL,
	[ParentRel2ID] [uniqueidentifier] NULL,
 CONSTRAINT [PK_ChildTable] PRIMARY KEY CLUSTERED 
(
	[ChildID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_ChildTable_Parent1]    Script Date: 09/11/2010 15:28:18 ******/
ALTER TABLE [dbo].[ChildTable]  WITH CHECK ADD  CONSTRAINT [FK_ChildTable_Parent1] FOREIGN KEY([ParentRel1ID], [ParentRel2ID])
REFERENCES [dbo].[ParentTable] ([ParentID], [Parent2ID])
GO
ALTER TABLE [dbo].[ChildTable] CHECK CONSTRAINT [FK_ChildTable_Parent1]
GO